<template>
  <div class="box">
    <h1>我的Vue项目</h1>
    <p>接收到的name是：{{ name }}</p>
    <p>接收到的age是：{{ age }}</p>
    <div class="main">
      <Left @passVal="getVal"></Left>
      <Right></Right>
    </div>
  </div>
</template>

<script>
// 导入Left、Right组件，并注册

import Left from './components/Left.vue'
import Right from './components/Right.vue'

export default {
  methods: {
    getVal(name, age) {
      // console.log(name, age)
      this.name = name
      this.age = age
    }
  },
  data() {
    return {
      name: '',
      age: 0
    }
  },

  // 注册组件
  components: {
    Left: Left,
    Right: Right
  }
}
</script>

<style lang="less" scoped>
.box {
  background-color: cornflowerblue;
  padding: 20px;
  .main {
    display: flex;
    > div {
      flex: 1;
      min-height: 300px;
      margin: 10px;
      padding: 10px;
    }
  }
}
</style>
